package com.coco.service.impl; 
import com.coco.service.UserService;
import com.coco.entity.User; 
import com.coco.entity.User; 
import java.util.List; 
import org.springframework.beans.factory.annotation.Autowired; 
import org.springframework.stereotype.Service; 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 
import com.coco.mapper.UserMapper; 

@Service 
public class UserServiceImpl implements UserService{ 
      private UserMapper userMapper; 

      @Autowired 
      public UserServiceImpl(UserMapper userMapper) { 
             this.userMapper = userMapper; 
} 



@Override 
      public List<User> queryPage(Integer pageNo, Integer pageSize) { 
             Page<User> page = userMapper.selectPage(new Page<>(pageNo, pageSize), new QueryWrapper<User>()); 
             List<User> recodes = page.getRecords(); 
             return recodes; 
} 


      @Override 
      public void add(User user){ 
             userMapper.insert(user); 
} 


      @Override 
      public void edit(User user){ 
             userMapper.updateById(user); 
} 


      @Override 
      public void delById(Integer id){ 
             userMapper.deleteById(id); 
} 


      @Override 
      public User getById(Integer id) { 
              return userMapper.selectById(id); 
} 
} 
